package com.example.lab2;

import org.achartengine.ChartFactory;
import org.achartengine.model.CategorySeries;
import org.achartengine.renderer.DefaultRenderer;
import org.achartengine.renderer.SimpleSeriesRenderer;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.app.Activity;


public class GraphActivity extends Activity{
	int food = 0;
	int transport = 0;
	int hobby = 0;
	int clothes = 0;
	int income = 0;
	
	public Intent getIntent(Context context) {
		int[] colors = new int[] { Color.RED, Color.YELLOW, Color.BLUE, Color.MAGENTA, Color.GREEN };
		DefaultRenderer renderer = buildCategoryRenderer(colors);

		CategorySeries categorySeries = new CategorySeries("Budget Chart");
		categorySeries.add("Food " + food + " kr", food);
		categorySeries.add("Transportation " + transport + " kr", transport);
		categorySeries.add("Hobby " + hobby + " kr", hobby);
		categorySeries.add("Clothes " + clothes + " kr", clothes);
		categorySeries.add("Income " + income + " kr", income);
		
		
		return ChartFactory.getPieChartIntent(context, categorySeries, renderer, null);
		}

		protected DefaultRenderer buildCategoryRenderer(int[] colors) {
		DefaultRenderer renderer = new DefaultRenderer();
		for (int color : colors) {
		SimpleSeriesRenderer r = new SimpleSeriesRenderer();
		r.setColor(color);
		renderer.addSeriesRenderer(r);
		}
		renderer.setChartTitle("Budget Chart");
		renderer.setChartTitleTextSize(30);
		renderer.setZoomButtonsVisible(true);
		renderer.setApplyBackgroundColor(true);
		renderer.setBackgroundColor(Color.rgb(205, 92, 92));
		
		
		return renderer;
		}
		
		public void setFood(int food) {
			this.food = food;
		}
		public void setTransport(int transport) {
			this.transport = transport;
		}
		public void setClothes(int clothes) {
			this.clothes = clothes;
		}
		public void setHobby(int hobby) {
			this.hobby = hobby;
		}
		public void setIncome(int income) {
			this.income = income;
		}
}